Skip to content

fix: report gRPC deadline races as cancellations - #1624

Merged
jlouvel merged 3 commits into
3.0from
fix/grpc-call-slot-before-close
Nov 2, 2026
Merged

jlouvel merged 3 commits into
3.0from
fix/grpc-call-slot-before-close

Conversation

@jlouvel

@jlouvel jlouvel commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1563 and #1623. The call-slot release that this PR first contained was merged with #1623, so this PR now keeps only the deadline and null-safety changes.

Changes

  • RestletClientStream, deadline races: when the client deadline expires, the grpc-java peer resets the stream with CANCEL, and the Restlet HTTP/2 client reports a closed connection. Such failures after the deadline are now reported as CANCELLED, like grpc-netty, so the SDK call ends with DEADLINE_EXCEEDED instead of UNAVAILABLE.
  • GrpcClientAdapter.getExecutor(): pairs the existing setExecutor(), so every setting has a getter.
  • Null-safety tightened in GuardedClientStream, RestletClientStream and the tests.
  • Tests:
    • RestletClientStreamTestCase covers the deadline races, with helpers shared by its tests.
    • The deadline tests of GrpcClientAdapterTestCase make a first call before the timed one, so class loading and the HTTP/2 connection no longer use up their 3-second deadline in a cold JVM.

Validation

./mvnw -B -pl org.restlet.ext.grpc -P default,test verify passes (tests, coverage, SpotBugs).

🤖 Generated with Claude Code

@jlouvel jlouvel self-assigned this Nov 1, 2026
@jlouvel
jlouvel force-pushed the fix/grpc-call-slot-before-close branch from f73794b to 4a26625 Compare November 1, 2026 21:21
@jlouvel jlouvel changed the title fix: free gRPC client call slots before closing calls fix: report gRPC deadline races as cancellations Nov 1, 2026
@jlouvel
jlouvel requested a balanced review from Copilot November 1, 2026 23:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The user-visible status-code change from UNAVAILABLE to DEADLINE_EXCEEDED is missing from the 3.0 Milestone 2 bug fixes in changes.md.

1 open issue
What changed in this PR

This follow-up adjusts the Restlet gRPC client’s deadline-race handling so expired calls report DEADLINE_EXCEEDED rather than UNAVAILABLE, building on the separately merged call-slot fix.

Changes:

  • Map transport failures after deadline expiry to cancellation and add regression tests.
  • Add an executor getter and null-safety-related adjustments.
  • Warm up deadline tests to reduce cold-start timing failures.
File Description
org.restlet.ext.grpc/​src/​test/​java/​org/​restlet/​ext/​grpc/​internal/​RestletClientStreamTestCase.java Adds deadline-status tests and shared helpers.
org.restlet.ext.grpc/​src/​test/​java/​org/​restlet/​ext/​grpc/​GrpcModuleTestCase.java Updates compiler invocation and diagnostic handling.
org.restlet.ext.grpc/​src/​test/​java/​org/​restlet/​ext/​grpc/​GrpcHttpValidationTestCase.java Adds explicit null checks to status assertions.
org.restlet.ext.grpc/​src/​test/​java/​org/​restlet/​ext/​grpc/​GrpcClientAdapterTestCase.java Adds warm-up calls and checks trailer availability.
org.restlet.ext.grpc/​src/​main/​java/​org/​restlet/​ext/​grpc/​internal/​RestletClientStream.java Tracks deadlines and maps expired transport failures to cancellation.
org.restlet.ext.grpc/​src/​main/​java/​org/​restlet/​ext/​grpc/​internal/​GuardedClientStream.java Suppresses null-analysis warnings.
org.restlet.ext.grpc/​src/​main/​java/​org/​restlet/​ext/​grpc/​GrpcClientAdapter.java Exposes the configured callback executor through a getter.

Review effort: Balanced

jlouvel and others added 3 commits November 1, 2026 20:59
Pair setExecutor with getExecutor, so that every GrpcClientAdapter setting has a getter, following the Restlet API conventions used across the RPC extensions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jerome Louvel <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jerome Louvel <[email protected]>
When the client deadline expires, the grpc-java peer resets the stream with CANCEL, and the Restlet HTTP/2 client reports it as a closed connection. Report such failures after the deadline as CANCELLED, like grpc-netty, so that the SDK call turns them into DEADLINE_EXCEEDED instead of UNAVAILABLE.

Make a first call in the deadline tests before the timed call, so that class loading and the HTTP/2 connection no longer exhaust their 3-second deadlines in a cold JVM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jerome Louvel <[email protected]>
@jlouvel
jlouvel force-pushed the fix/grpc-call-slot-before-close branch from 4a26625 to 2b9209e Compare November 2, 2026 02:02
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@jlouvel
jlouvel merged commit cacfd93 into 3.0 Nov 2, 2026
3 checks passed
@jlouvel
jlouvel deleted the fix/grpc-call-slot-before-close branch November 2, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants